package com.ning;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.RenderedImage;
import java.io.File;
import java.io.IOException;

/*
@李子宁
Happy,happy everyday!
冲鸭！
2021/5/7

*/
public class PngToJson {
    public static void main(String[] args) {
        Image[] array = new Image[10];
        Image image = null;//这里是你要读取的图像文件
        try {
            image = ImageIO.read(new File("D:\\IntelliJ IDEA-workspace\\Basic\\day01-code\\mavens-project\\src\\main\\resources\\xiazai.png"));
        } catch (IOException e) {
            e.printStackTrace();
        }
        array[0] = image;
        try {
            ImageIO.write((RenderedImage) image, "png", new File("D:\\IntelliJ IDEA-workspace\\Basic\\day01-code\\mavens-project\\src\\main\\resources\\result.json"));//这里是你要写入的文件，如果不存在这个文件，那么系统会自动创建它
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
